package unittest;

import junit.framework.TestCase;

import java.io.File;
import java.io.IOException;

import compiler.Compiler;

/**
 * Created by IntelliJ IDEA.
 * User: aleck
 * Date: 2007-9-28
 * Time: 20:59:02
 * To change this template use File | Settings | File Templates.
 */
public class CompilerTest extends TestCase {
  public final String baseDir = System.getProperty("user.dir") + "\\" + "test";

  public void testCompileCpp() throws IOException {
    File cpp = new File(baseDir + "\\" + "t1.cpp");
    File exe = new File(baseDir + "\\" + "t1.exe");
    if (exe.exists()) exe.delete();
    Compiler.compile(cpp);
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }
    assertTrue(exe.exists());
  }

  public void testCompileC() throws IOException {
    File c = new File(baseDir + "\\" + "t2.c");
    File exe = new File(baseDir + "\\" + "t2.exe");
    if (exe.exists()) exe.delete();
    Compiler.compile(c);
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }
    assertTrue(exe.exists());
  }
}
